home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
pctj8504.arc
/
KEYGEN.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1986-09-14
|
1KB
|
65 lines
PROGRAM keygen;
{This program may be freely copied and modified.}
{$R+}
TYPE
subrange1 = 1..128;
subrange2 = 1..64;
VAR
i: subrange1;
j: subrange2;
sum, keysum: INTEGER;
subKey: ARRAY[1..128] OF INTEGER;
transKey: ARRAY[1..64] OF INTEGER;
datafile: TEXT;
PROCEDURE subKeygen;
BEGIN
RANDOMIZE;
FOR i:=1 TO 128 DO subKey[i]:=RANDOM(128);
END;
PROCEDURE swap(VAR left,right: INTEGER);
VAR
tempStore: INTEGER;
BEGIN
tempStore:=left;
left:=right;
right:=tempStore;
END;
PROCEDURE transKeygen;
VAR
r: INTEGER;
BEGIN
RANDOMIZE;
FOR j:=1 TO 64 DO transKey[j]:=j;
FOR j:=1 TO 64 DO
BEGIN
r:=RANDOM(65);
IF r = 0 THEN r:=1;
swap(transKey[j],transKey[r]);
END;
END;
BEGIN
subKeygen;
transKeygen;
sum:=0; keysum:=0;
FOR j:=1 TO 64 DO
BEGIN
sum:=sum+j;
keysum:=transKey[j] + keysum;
END;
WRITELN('Sum =',sum,' Keysum =',keysum);
ASSIGN(datafile,'keyfile');
REWRITE(datafile);
FOR i:=1 TO 128 DO WRITE(datafile,subKey[i],' ');
WRITELN(datafile);
FOR j:=1 TO 64 DO WRITE(datafile,transKey[j],' ');
CLOSE(datafile);
END.